package com.sky.service.admin.impl;

import com.sky.mapper.admin.WorkspaceMapper;
import com.sky.service.admin.WorkspaceService;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.DishViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@Service
public class WorkspaceServiceImpl implements WorkspaceService {
    @Autowired
    private WorkspaceMapper workspaceMapper;

    @Override
    public DishOverViewVO selectDishes() {
      List<Map> dishLishs=  workspaceMapper.selectDishes();

        List<Object> count = dishLishs.stream().map(dishLish -> {
            return dishLish.get("count");
        }).collect(Collectors.toList());
        Integer sold =(Integer) count.get(0);
        Integer discontinued =(Integer) count.get(0);
        return new DishOverViewVO(sold,discontinued);
    }
}
